<?php
session_start();
$currPage = "manage";
include("inc_header.php"); ?>

	<div id="content">
		<h2><a href="#">Pending Notifications</a></h2>
		<p>The following are notifications that you've sent and are still pending review by the owner... Keep your fingers crossed!</p>
		<div class="clearfix">
			<?php
			
			$host="mysql-user.cse.msu.edu"; // Host name
			$username="hewittry"; // Mysql username
			$password="A39777266"; // Mysql password
			$db_name="hewittry"; // Database name

			mysql_connect("$host", "$username", "$password")or die("cannot connect");
			mysql_select_db("$db_name")or die("cannot select DB");
			
			$query = "SELECT * FROM Notification, VehicleForSale, NonAdmins WHERE Notification.RegisteredUser_NonAdmins_AllUsers_LogonID = NonAdmins.AllUsers_LogonID AND Notification.VehicleForSale_VehicleForSaleID = VehicleForSale.VehicleForSaleID AND RegisteredUser_NonAdmins_AllUsers_LogonID = '" . $_SESSION["username"] . "' ORDER BY Notification.Timestamp;";
			$result = mysql_query($query) or die(mysql_error());;
			$html = "";
			while ($row = mysql_fetch_assoc($result))
			{
				$html .= "<li>" . date(' h:i:s A F j, Y', $row['Timestamp']). " - <a href='viewCar.php?id=". $row['VehicleForSaleID'] . "'>" . $row['VehicleYear'] . " " . $row['Make'] . " " . $row['Model'] . "</a>. </li>";
			}
			echo ($html == "") ? "Whoops! No current messages. Have you <a href='postAnnouncement.php'>posted an announcement</a> yet?" : "<ul>" . $html . "</ul>";
			?>
		</div>
	</div>

<?php include("inc_footer.php"); ?>
